import 'dart:ui';

import 'package:flutter/material.dart';

import '../compant/Appcolor.dart';
import '../compant/Kbutton.dart';
import '../compant/Kbuttonwhite.dart';
import 'logAccount.dart';

class ob1 extends StatefulWidget {
  const ob1({super.key});

  @override
  State<ob1> createState() => _ob1State();
}

class _ob1State extends State<ob1> {
  late final PageController controller;
  int count = 0;
  List strs = [
    'It was a \nhumorously.',
    'So strongly and \nmetap.',
    'The monkey-rope \nis foxic'
  ];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    controller = PageController()
      ..addListener(() {
        setState(() {
          count = controller.page!.round();
        });
      });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Padding(
        padding: const EdgeInsets.all(30.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                SizedBox(
                  height: 500,
                  child: PageView(
                    controller: controller,
                    children: [
                      Container(
                        color: Colors.cyan,
                      ),
                      Container(
                        color: Colors.white,
                      ),
                      Container(
                        color: Colors.cyan,
                      )
                    ],
                  ),
                ),
                Row(
                  children: List.generate(3, (index) => buildindicator(index)),
                ),
                Text(
                  strs[count],
                  style: TextStyle(
                    color: textColor,
                    fontSize: 26,
                  ),
                  textAlign: TextAlign.start,
                ),
              ],
            ),
            Text(
              'Get notifications\nand updates in real time.',
              style: TextStyle(color: textGaryColor, fontSize: 16),
              textAlign: TextAlign.start,
            ),
            Kbutton(
              ontap: () {
                Navigator.push(context,
                    MaterialPageRoute(builder: (BuildContext context) {
                  return LogAccount();
                }));
              },
              text: 'Get Started',
            ),
            Kbuttonwhite(
              ontap: () {},
              text: 'Do not allow',
            ),
          ],
        ),
      ),
    );
  }

  Container buildindicator(index) {
    return Container(
      width: 30,
      height: 5,
      margin: EdgeInsets.symmetric(vertical: 10, horizontal: 5),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10),
          color: count == index ? buttomBgc : Colors.blue),
    );
  }
}
